import datetime
import time
import random


def is_after(a, b):
    return (a - b).days > 0


def is_equals(a, b):
    return (a - b).days == 0


def is_week_end(year, month, day):
    weekday = datetime.datetime(year, month, day).strftime("%w")

    if int(weekday) > 4:
        return True
    else:
        return False


def is_valid_date(year, month, day):
    try:
        datetime.datetime(year, month, day)
        return True
    except:
        return False


def random_time(startTime, endTime):
    start = time.strptime(startTime, "%Y-%m-%d %H:%M:%S")
    end = time.strptime(endTime, "%Y-%m-%d %H:%M:%S")
    return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(random.uniform(time.mktime(start), time.mktime(end)))
                         )

# def test(day, start, end):
#     D = str(2014) + "-" + str(11) + "-" + str(day) + " "
#     random_time(D + start, D + end)
#
#
# print test(10, "7:00:00", "9:00:00")
